<template>
    <div id="app">
        <button @click="switchLanguage">切换语言</button>
        <p>{{$t('hello')}}</p>
        <router-view></router-view>
    </div>
</template>

<script>
export default {
    name: 'App',
    data(){
        return {
        }
    },
    created(){
        console.log(this.$router)
    },
    computed: {
        lang(){
            return this.$i18n.locale
        }
    },
    methods: {
        switchLanguage(){ // 切换语言
            let lang = window.localStorage.getItem('language')
            lang == 'en' ? lang = 'cn' : lang = 'en'
            this.curLangage = lang
            window.localStorage.setItem('language', lang)
            this.$i18n.locale = lang
        },
    }
}
</script>

<style lang="scss">
    p {
        color: $primary-color;
    }
</style>